<?php

header("content-type: text/html; charset=iso-8859-1;", true);

$dbHost = "127.0.0.1:3306";
$dbUser = "root";
$dbPass = "babilonia";
$dbData = "reservas";

$conn = mysql_connect($dbHost,$dbUser,$dbPass) or die(mysql_error());
mysql_select_db($dbData,$conn) or die(mysql_error());

mysql_query("SET NAMES 'utf8';");

if($conn){
	$sql_select = mysql_query("SELECT * FROM tab_equipamento ORDER BY Nome ASC");
	
	$qnt = mysql_num_rows($sql_select);
	
	if($qnt > 0) {
		while($row= mysql_fetch_assoc($sql_select)) {
         	$record = array(
				'IDEquipamento' => $row["IDEquipamento"],
				'Equipamento' => $row["Nome"]
	        );
	        $response['rows'][] = $record;
     	}
	}
}

echo json_encode($response);
?>